﻿@{
    ViewBag.Title = "任务列表";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}
@section scripts{
    <script src="../Scripts/jquery.AnkeExtend.js"> </script> 
    <script type="text/javascript">     
        //页面动态改动
        $(window).resize(function () {
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
        });

        //页面初始化
        $(document).ready(function () {
            DisableBackspace();
            $('#editWindow').window('close'); // 默认隐藏查看详细信息窗口

            //取所属分中心的下拉框的值
            $("#center").combobox({
                url: '@Url.Content("~/BB/AllDictionary/GetCenterName")',
                valueField: 'ID',
                textField: 'Name',
                editable: false,
                multiple: true,
                prompt: '--请选择--',
                onSelect: function (rec) {
                    var ids = $('#center').combobox('getValues');
                    //根据分中心取分站
                    $("#station").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#station').combobox('getValues');
                            var sids = $('#station').combobox('getValues');
                            //根据分站取车辆
                            $("#actualNumber").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#actualNumber').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#actualNumber').combobox('getValues')
                                }
                            });
                        },
                        onUnselect: function () {
                            $('#station').combobox('getValues');
                            var sids = $('#station').combobox('getValues');
                            //根据分站取车辆
                            $("#actualNumber").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#actualNumber').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#actualNumber').combobox('getValues')
                                }
                            });
                        }
                    });
                    $("#station").combobox('clear');
                    $("#actualNumber").combobox('clear');
                },
                onUnselect: function (rec) {
                    var ids = $('#center').combobox('getValues');
                    //根据分站取车辆
                    $("#station").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#station').combobox('getValues');
                            var sids = $('#station').combobox('getValues');
                            //根据分站取车辆
                            $("#actualNumber").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#actualNumber').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#actualNumber').combobox('getValues')
                                }
                            });
                            $("#actualNumber").combobox('clear');
                        },
                        onUnselect: function () {
                            $('#station').combobox('getValues');
                            var sids = $('#station').combobox('getValues');
                            //根据分站取车辆
                            $("#actualNumber").combobox({
                                url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                                method: 'POST',
                                valueField: 'ID',
                                textField: 'Name',
                                multiple: true,
                                editable: false,
                                onSelect: function () {
                                    $('#actualNumber').combobox('getValues')
                                },
                                onUnselect: function () {
                                    $('#actualNumber').combobox('getValues')
                                }
                            });
                            $("#actualNumber").combobox('clear');
                        }                 
                    });
                    $("#station").combobox('clear');
                    $("#actualNumber").combobox('clear');
                }
                 
            });
       
            var centers = $('#center').combobox('getValues');
            $("#station").combobox({
                url: '@Url.Content("~/BB/AllDictionary/GetSationName?centerID=")' + centers,
                method: 'POST',
                valueField: 'ID',
                textField: 'Name',
                multiple: true,
                editable: false,
                prompt: '--请选择--',
                onSelect: function () {
                    $('#station').combobox('getValues');
                    var sids = $('#station').combobox('getValues');
                    //根据分中心取分站
                    $("#actualNumber").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + sids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#actualNumber').combobox('getValues')
                        },
                        onUnselect: function () {
                            $('#actualNumber').combobox('getValues')
                        }
                    });              
                },
                onUnselect: function () {
                    $('#station').combobox('getValues');
                    var ids = $('#station').combobox('getValues');
                    //根据分站取车辆
                    $("#actualNumber").combobox({
                        url: '@Url.Content("~/BB/AllDictionary/GetAmbulanceName?stationID=")' + ids,
                        method: 'POST',
                        valueField: 'ID',
                        textField: 'Name',
                        multiple: true,
                        editable: false,
                        onSelect: function () {
                            $('#actualNumber').combobox('getValues')
                        },
                        onUnselect: function () {
                            $('#actualNumber').combobox('getValues')
                        }
                    });

                }
            });

           

            //取实际标识
            $.EUIcombobox("#actualNumber", {
                url: '@Url.Content("~/DD/EventInfo/GetAmbulanceCode/")',
                valueField: 'ID',
                textField: 'Name',
                editable: true,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //取司机
            $.EUIcombobox("#driver", {
                url: '@Url.Content("~/DD/EventInfo/GetDriver/")',
                valueField: 'Name',
                textField: 'Name',
                editable: true,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //取医生
            $.EUIcombobox("#doctor", {
                url: '@Url.Content("~/DD/EventInfo/GetDoctor/")',
                valueField: 'Name',
                textField: 'Name',
                editable: true,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //取护士
            $.EUIcombobox("#nurse", {
                url: '@Url.Content("~/DD/EventInfo/GetNurse/")',
                valueField: 'Name',
                textField: 'Name',
                editable: true,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });
            //取担架员
            $.EUIcombobox("#stretcher", {
                url: '@Url.Content("~/DD/EventInfo/GetStretcher/")',
                valueField: 'Name',
                textField: 'Name',
                editable: true,
                OneOption: [{
                    ID: "",
                    Name: "--请选择--"
                }]
            });

            $('#start').datetimebox('setValue', '@ViewData["start"]');
            $('#end').datetimebox('setValue', '@ViewData["end"]');
            bindGrid();
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
        })

        function bindGrid() {
            $('#grid').datagrid({
                width: 'auto',
                height: 'auto',
                fitColumns: true,
                striped: true,
                singleSelect: true,
                url: '@Url.Content("~/DD/Task/DataLoad")',
                loadMsg: '数据加载中请稍后……',
                pagination: true,//启用分页
                rownumbers: true,//显示页码
                pageSize: 15,//设置 页容量
                pageList: [10, 15, 20],//设置 页容量下拉框
                queryParams: {
                    center: $('#center').combobox('getValues').join(','),
                    station: $('#station').combobox('getValues').join(','),
                    actualNumber: $('#actualNumber').combobox('getValues').join(','),
                    ambulanceNumber: $('#ambulanceNumber').textbox('getValue'),
                    driver: $('#driver').combobox('getValue'),
                    doctor: $('#doctor').combobox('getValue'),
                    nurse: $('#nurse').combobox('getValue'),
                    stretcher: $('#stretcher').combobox('getValue'),
                    start: $('#start').datetimebox('getValue'),
                    end: $('#end').datetimebox('getValue'),
                    localAdr: $('#localAdr').textbox('getValue'),
                    pName: $('#pName').textbox('getValue'),
                    sendAdr: $('#sendAdr').textbox('getValue'),
                    callNumber: $('#callNumber').textbox('getValue'),
                    contactTelephone: $('#contactNumber').textbox('getValue')
                },
                columns: [[
                   { title: '呼救电话', field: 'callNumber', width: '8%', align: "center", sortable: false },
                   { title: '现场地址', field: 'localAdr', width: '20%', align: "center", sortable: false },
                   { title: '患者姓名', field: 'pName', width: '6%', align: "center", sortable: false },
                   { title: '分中心', field: 'center', width: '6%', align: "center", sortable: false },
                   { title: '分站', field: 'station', width: '6%', align: "center", sortable: false },
                   { title: '车号', field: 'actualNumber', width: '7%', align: "center", sortable: false },
                   //{ title: '司机', field: 'driver', width: '6%', align: "center", sortable: false },
                   //{ title: '医生', field: 'doctor', width: '6%', align: "center", sortable: false },
                   //{ title: '护士', field: 'nurse', width: '6%', align: "center", sortable: false },
                   //{ title: '担架员', field: 'stretcher', width: '10%', align: "center", sortable: false },
                   { title: '随车人员', field: 'driver', width: '28%', align: "center", sortable: false },
                   { title: '任务生成时刻', field: 'taskGenerationTime', width: '12%', align: "center", sortable: false },
                   { title: '病历个数', field: 'patientRecordNumber', width: '6%', align: "center", sortable: false },
                   { title: '事件编码', field: 'EventCode', width: '10%', align: "center", sortable: false, hidden: true },
                ]],
                toolbar: [
                    {
                        id: 'btnView',
                        text: '<span style="color:red;font-size:large">查看详细</span>',
                        iconCls: 'icon-redo',
                        handler: function () {
                            var selected = $('#grid').datagrid('getSelected');
                            if (selected) {
                                window.open('@Url.Content("~/DD/AcceptEvent/AcceptEventTaskList?EventCode=")' + selected.EventCode);
                            } else {
                                $.messager.alert('提示', '请选择数据行', 'info', function () {
                                });
                            }
                        }           
                    }
                ]
            })    
            $.setGridWithSearchBar("#TableForm", "#SearchBar", "#grid");
        }

        //查询
        function reSearch() {
            $('#grid').datagrid({
                pageNumber: 1,//点击查询返回第一页
                queryParams: {
                    center: $('#center').combobox('getValues').join(','),
                    station: $('#station').combobox('getValues').join(','),
                    actualNumber: $('#actualNumber').combobox('getValues').join(','),
                    ambulanceNumber: $('#ambulanceNumber').textbox('getValue'),
                    driver: $('#driver').combobox('getValue'),
                    doctor: $('#doctor').combobox('getValue'),
                    nurse: $('#nurse').combobox('getValue'),
                    stretcher: $('#stretcher').combobox('getValue'),
                    start: $('#start').datetimebox('getValue'),
                    end: $('#end').datetimebox('getValue'),
                    localAdr: $('#localAdr').textbox('getValue'),
                    pName: $('#pName').textbox('getValue'),
                    sendAdr: $('#sendAdr').textbox('getValue'),
                    callNumber: $('#callNumber').textbox('getValue'),
                    contactTelephone: $('#contactNumber').textbox('getValue')
                }
            })
        }
    </script>
}
<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'任务列表',iconCls:'icon-custom-Entry'">
        <div id="SearchBar" data-options="region:'center'" style="overflow: hidden; padding: 10px">
            <table style="width:99%" cellpadding="0" cellspacing="5" border="0">
                <tr>
                    <td align="right" valign="middle" width="9%">任务生成时刻：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="start" class="easyui-datetimebox" value=@ViewData["start"] style="width:150px" data-options="editable:false"/>
                    </td>
                    <td align="right" valign="middle" width="9%">至：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="end" class="easyui-datetimebox" value=@ViewData["end"] style="width:150px" data-options="editable:false" />
                    </td>
                    <td align="right" valign="middle" width="9%">呼救电话：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="callNumber" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">联系电话：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="contactNumber" class="easyui-textbox" style="width:150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" width="9%">患者姓名：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="pName" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">司机：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="driver" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">医生：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="doctor" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">担架员：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="stretcher" class="easyui-combobox" style="width:150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" width="9%">分中心：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="center" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">分站：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="station" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">车号：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="actualNumber" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">车牌号码：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="ambulanceNumber" class="easyui-textbox" style="width:150px" />
                    </td>
                </tr>
                <tr>
                    <td align="right" valign="middle" width="9%">现场地址：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="localAdr" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">送往地点：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="sendAdr" class="easyui-textbox" style="width:150px" />
                    </td>
                    <td align="right" valign="middle" width="9%">护士：</td>
                    <td align="right" valign="middle" width="13%">
                        <input id="nurse" class="easyui-combobox" style="width:150px" />
                    </td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td align="center" valign="middle" width="11%">                        
                        <a href="javascript:void(0)" id="btnsearch" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reSearch()">查询</a>
                    </td>
                </tr>
            </table>
        </div>
        <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
            <table id="grid"></table>
        </div>
    </div>
</div>

